﻿<!DOCTYPE HTML>
<html>
	<head>
		<title>chapter5_function</title>
	</head>
	<body>
		<script type="text/javascript">
			//test define a function
			/*
			function sum(num1,num2){
				return num1+num2;
			}
			alert(sum('leima',' ok'));
			
			var sum2 = function(num1,num2){
				return num1+num2;
			};
			alert(sum2(1,2));
			*/
			/*
			function sum(num1,num2){
				return num1+num2;
			}
			var sum2 = sum;
			alert(sum('leima',' ok'));
			sum = null;
			alert(sum2('leima',' ok'));
			*/
			//test no reload
			/*
			function tf1(){
				alert('tf1');
			}
			function tf1(){
				alert('tf2');
			}
			tf1();
			
			
			alert(sum(1,2));
			function sum(num1,num2){
				return num1+num2;
			}

			alert(sum2(1,2));
			var sum2 = function(num1,num2){
				return num1+num2;
			};
			*/

			var object = {
				id:1,
				name:'test',
				function1 : function(){
					alert('object');
				}
			};
			object.function1();
		</script>
	</body>	
</html>